<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/5/24
  Time: 14:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>登陆</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=1" />
    <link rel="stylesheet" href="/wechat/login/signup.css">
    <jsp:include page="../public/head.jsp" flush="true" />

</head>
<body>
<!-- 头部 -->
<%--<header>--%>
    <%--<div class="h-l"><i class="iconfont icon-person">&#xe601;</i></div>--%>
<%--</header>--%>
<!-- 导航 -->
<!-- 导航 -->
<section >
    <div class="my_signup">
        <img src="/wechat/images/bg_signin.jpg">
        <form onsubmit="false" id="form" method="post">
            <div class="row1">
                <i class="iconfont icon-phone">&#xe605;</i>
                <input type="text" id="mobile" name="mobile" value="" placeholder="请输入手机号码" class="user-name" data-caution="用户名不能为空">
            </div>
            <!--/row-->

            <div class="row1">
                <i class="iconfont icon-phone">&#xe600;</i>
                <input type="password" id="password" name="password" value="" placeholder="输入6~16位数字或者字母" class="user-name" data-caution="用户名不能为空">
            </div>

            <input type="hidden" value="wechat" name="platform">
            <!--/row-->
            <input type="button" value="登录" class="user-agree" onclick="login()">
            <%--<a href="<c:url value="/wechat/login/register.jsp"/>" class="agreement"><span>免费注册</span></a>--%>
            <a href="/home/chooseCity.do?lastpage=register" class="agreement" id="register"><span>免费注册</span></a>
            <a href="/beforelogin/forgetPwd.do" class="forgetPd"><span>忘记密码？</span></a>
            <a href="/home/chooseCity.do" class="whatEver"><span>不登录 随便逛逛 》</span></a>
        </form>

    </div>
</section>
<script>

    $(function(){
        if(localStorage.getItem("zfMobile")!=null&&localStorage.getItem("zfPassWord")!=null
                &&localStorage.getItem("zfMobile")!=""
            &&localStorage.getItem("zfPassWord")!=""){

            $.ajax({
                url:"/mobile/user?action=login",
                data:{mobile:localStorage.getItem("zfMobile"),password:localStorage.getItem("zfPassWord")},
                type:"post",
                dataType:"json",
                success:function(data){
                    if (!data.success){
                        tip("my_signup",data.msg,true);
                        localStorage.removeItem("zfMobile");
                        localStorage.removeItem("zfPassWord");


                    }else {
                        localStorage.setItem("zfMobile",$("#mobile").val());
                        localStorage.setItem("zfPassWord",$("#password").val());
                        window.location.href = "/home/beforelogin/index.do";
                    }
                }
            });


        }
    });

    function login() {
        if ($("#mobile").val().length == 0 || $("#mobile").val() == ""){
            tip('my_signup',"还未输入手机号",true);
//            alert("还未输入手机号");
            return;
        }
        if ($("#password").val().length == 0){
            tip("my_signin","还未输入密码",true);
            return;
        }

        $.post("/mobile/user?action=login",$("#form").serialize(),
                function(data){
                    if (!data.success){
                        tip("my_signup",data.msg,true);
                        localStorage.removeItem("zfMobile");
                        localStorage.removeItem("zfPassWord");
                    }else {
                        localStorage.setItem("zfMobile",$("#mobile").val());
                        localStorage.setItem("zfPassWord",$("#password").val());
                        window.location.href = "/home/beforelogin/index.do";
                    }
                },"json");
    }
    function GetQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var from =  GetQueryString("from");
     if (from!=null){

         //设置注册超链接

         window.localStorage.setItem("from",from);


         //添加进入记录

         $.post("/accountFrom?action=count",{fromtype:from},
                 function(data){
                       console.log(data);
                 },"json");
     }



</script>
</body>
</html>
